import axios from 'wx-axios-promise'
import Toast from '@vant/weapp/toast/toast'
const ajaxUrl = 'https://www.zl-ai.com';
let ajax = axios({
    url: ajaxUrl,
    timeout: 60000
});
// http请求拦截器
ajax.interceptors.request.use(config => {
    let oaCode = wx.getStorageSync('oaCode');
    oaCode ? config.header['oaCode'] = oaCode : wx.reLaunch({
      url: '/pages/start/start',
    })
    return config
});
// http响应拦截器
ajax.interceptors.response.use(res => {
    // console.log('响应拦截器----------', res)
    return res
});
ajax.toast = Toast
ajax.loading = function () {
    Toast.loading({
        forbidClick: true,
        duration: 'toast',
        message: '加载中...'
    });
};

export default ajax